<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="PTA程序设计习题, 阿狸的日志">
    <meta name="description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>PTA程序设计习题 | 阿狸的日志</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>

<meta name="generator" content="Hexo 5.4.0"></head>




<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">阿狸的日志</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">阿狸的日志</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
    </ul>
</div>


        </div>

        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/12.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">PTA程序设计习题</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84-%E7%AE%97%E6%B3%95/">
                                <span class="chip bg-color">数据结构,算法</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/%E7%BC%96%E7%A8%8B/" class="post-category">
                                编程
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2022-10-06
                </div>
                

                

                

                

                
            </div>
        </div>
        <hr class="clearfix">

        
        <!-- 是否加载使用自带的 prismjs. -->
        <link rel="stylesheet" href="/libs/prism/prism.css">
        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <p>@<a href="%E6%96%87%E7%AB%A0%E7%9B%AE%E5%BD%95">TOC</a></p>
<h2 id="7-1-PY圆面积"><a href="#7-1-PY圆面积" class="headerlink" title="7-1 PY圆面积"></a>7-1 PY圆面积</h2><p>编写程序，输入圆的半径，计算圆的面积并输出。</p>
<p>提示：圆的计算公式为area=π×radius2，在这道题中，π取<code>3.14159</code>。</p>
<h3 id="输入格式"><a href="#输入格式" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入为一个大于0的浮点数，表示圆的半径。</p>
<h3 id="输出格式"><a href="#输出格式" class="headerlink" title="输出格式:"></a>输出格式:</h3><p>输出一个浮点数，小数点后输出两位，表示圆的面积。</p>
<h3 id="输入样例"><a href="#输入样例" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>  3.2</p>
<h3 id="输出样例"><a href="#输出样例" class="headerlink" title="输出样例:"></a>输出样例:</h3><p>  32.17</p>
<pre class="line-numbers language-Python" data-language="Python"><code class="language-Python">radius &#x3D; float(input())
pi &#x3D; 3.14159
area &#x3D; pi*radius**2
print(&quot;%.2f&quot;%area)<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-2-求正弦值-输入角度"><a href="#7-2-求正弦值-输入角度" class="headerlink" title="7-2 求正弦值 输入角度"></a>7-2 求正弦值 输入角度</h2><p>求正弦值。pi使用系统定义的pi值。</p>
<h3 id="输入格式-1"><a href="#输入格式-1" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入角度，小数</p>
<h3 id="输出格式-1"><a href="#输出格式-1" class="headerlink" title="输出格式:"></a>输出格式:</h3><p>输出正弦值，保留两位小数</p>
<h3 id="输入样例-1"><a href="#输入样例-1" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>在这里给出一组输入。例如：</p>
<p>  45</p>
<h3 id="输出样例-1"><a href="#输出样例-1" class="headerlink" title="输出样例:"></a>输出样例:</h3><p>在这里给出相应的输出。例如：</p>
<p>  0.71</p>
<pre class="line-numbers language-Python" data-language="Python"><code class="language-Python">import math
i &#x3D; float(input())
result &#x3D; math.sin((math.pi&#x2F;180)*i)
print(&quot;%.2f&quot;%result)<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-3-PY时间差"><a href="#7-3-PY时间差" class="headerlink" title="7-3 PY时间差"></a>7-3 PY时间差</h2><p>10点半到11点45之间，有几小时几分钟呢？</p>
<p>你要写一个程序，读入两个时间，计算它们之间的时间差，输出相差几小时几分钟。</p>
<h3 id="输入格式-2"><a href="#输入格式-2" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入两行，分别表示两个时间，均以24小时制表达，每个时间以“小时 分钟”的形式表达，第二个时间一定比第一个时间晚或相同，而且一定在同一天内。</p>
<h3 id="输出格式-2"><a href="#输出格式-2" class="headerlink" title="输出格式:"></a>输出格式:</h3><p>输出表示两个时间之间的时间差的两个数字，第一个数字是时间差中的小时数，第二个数字是时间差中的分钟数。</p>
<h3 id="输入样例-2"><a href="#输入样例-2" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>  10 30 </p>
<p>  11 45</p>
<h3 id="输出样例-2"><a href="#输出样例-2" class="headerlink" title="输出样例:"></a>输出样例:</h3><p>  1 15</p>
<h4 id="使用最简单的方式"><a href="#使用最简单的方式" class="headerlink" title="使用最简单的方式"></a>使用最简单的方式</h4><pre class="line-numbers language-Python" data-language="Python"><code class="language-Python">old &#x3D; input()
new &#x3D; input()
old_h,old_s &#x3D; old.split(&quot; &quot;)[0],old.split(&quot; &quot;)[1]
new_h,new_s &#x3D; new.split(&quot; &quot;)[0],new.split(&quot; &quot;)[1]
old_h,old_s,new_h,new_s &#x3D; list(map(lambda x:int(x),[old_h,old_s,new_h,new_s]))
result_h &#x3D; new_h - old_h
result_s &#x3D; new_s - old_s
print(result_h,result_s)<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h4 id="利用date"><a href="#利用date" class="headerlink" title="利用date"></a>利用date</h4><pre class="line-numbers language-Python" data-language="Python"><code class="language-Python">from datetime import datetime

def calc_hours(old: str, new: str)-&gt;float:
    old_time &#x3D; datetime.strptime(old, &quot;%Y-%m-%d %H:%M:%S&quot;)
    new &#x3D; datetime.strptime(new, &quot;%Y-%m-%d %H:%M:%S&quot;)
    sec &#x3D; (new - old_time).seconds
    return round(sec&#x2F;3600, 3)


old &#x3D; input().replace(&quot; &quot;, &quot;:&quot;)
new &#x3D; input().replace(&quot; &quot;, &quot;:&quot;)
time_1 &#x3D; f&#39;2020-01-01 &#123;old&#125;:00&#39;
time_2 &#x3D; f&#39;2020-01-01 &#123;new&#125;:00&#39;
result &#x3D; calc_hours(time_1, time_2)
if(result&gt;1):
    integer &#x3D; result%result+1
    decimal &#x3D; (float(result)-float(integer))*60
print(&quot;%d %d&quot;%(integer,decimal))<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h4 id="利用三方库numpy"><a href="#利用三方库numpy" class="headerlink" title="利用三方库numpy"></a>利用三方库numpy</h4><pre class="line-numbers language-Python" data-language="Python"><code class="language-Python">from datetime import datetime
import numpy as np

def calc_hours(old: str, new: str)-&gt;float:
    old_time &#x3D; datetime.strptime(old, &quot;%Y-%m-%d %H:%M:%S&quot;)
    new &#x3D; datetime.strptime(new, &quot;%Y-%m-%d %H:%M:%S&quot;)
    sec &#x3D; (new - old_time).seconds
    return round(sec&#x2F;3600, 3)


old &#x3D; input().replace(&quot; &quot;, &quot;:&quot;)
new &#x3D; input().replace(&quot; &quot;, &quot;:&quot;)
time_1 &#x3D; f&#39;2020-01-01 &#123;old&#125;:00&#39;
time_2 &#x3D; f&#39;2020-01-01 &#123;new&#125;:00&#39;
result &#x3D; calc_hours(time_1, time_2)
adecimal,integer&#x3D;np.modf(result)
print(adecimal,integer)<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-2-计算存款利息"><a href="#7-2-计算存款利息" class="headerlink" title="7-2 计算存款利息"></a>7-2 计算存款利息</h2><p>本题目要求计算存款利息，计算公式为interest=money×(1+rate)<br>year<br> −money，其中interest为存款到期时的利息（税前），money是存款金额，year是存期，rate是年利率。</p>
<p>输入格式：<br>输入在一行中顺序给出三个正实数money、year和rate，以空格分隔。</p>
<p>输出格式：<br>在一行中按“interest = 利息”的格式输出，其中利息保留两位小数。</p>
<p>输入样例：<br>1000 3 0.025<br>输出样例：<br>interest = 76.89</p>
<pre class="line-numbers language-c" data-language="c"><code class="language-c"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;math.h></span></span>

<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token comment">//本题目要求计算存款利息，计算公式为interest=money*(1+rate)^year-money</span>
    <span class="token comment">//其中interest为存款到期时的利息（税前），money是存款金额，year是存期，rate是年利率。</span>

    <span class="token comment">//输入在一行中顺序给出三个正实数money、year和rate，以空格分隔。</span>
    <span class="token comment">//在一行中按“interest = 利息”的格式输出，其中利息保留两位小数。</span>
    <span class="token comment">//输入样例1000 3 0.025</span>

    <span class="token keyword">float</span> money<span class="token punctuation">;</span>
    <span class="token keyword">float</span> year<span class="token punctuation">;</span>
    <span class="token keyword">float</span> rate<span class="token punctuation">;</span>
    <span class="token keyword">float</span> interest<span class="token punctuation">;</span>
    <span class="token keyword">int</span> result <span class="token operator">=</span> <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%f %f %f"</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>money<span class="token punctuation">,</span> <span class="token operator">&amp;</span>year<span class="token punctuation">,</span> <span class="token operator">&amp;</span>rate<span class="token punctuation">)</span><span class="token punctuation">;</span>
    interest <span class="token operator">=</span> money <span class="token operator">*</span> <span class="token function">powf</span><span class="token punctuation">(</span><span class="token number">1</span> <span class="token operator">+</span> rate<span class="token punctuation">,</span> year<span class="token punctuation">)</span> <span class="token operator">-</span> money<span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"interest = %.2f\n"</span><span class="token punctuation">,</span> interest<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-3-字符反序输出，并去ASCII码值之和"><a href="#7-3-字符反序输出，并去ASCII码值之和" class="headerlink" title="7-3 字符反序输出，并去ASCII码值之和"></a>7-3 字符反序输出，并去ASCII码值之和</h2><p>从键盘输入3个字符，将它们反向输出，并输出这3个字符ASCII码值之和。</p>
<h3 id="输入格式-3"><a href="#输入格式-3" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>在一行中输入3个字符，每个字符之间用空格分隔。</p>
<p>输出格式:<br>在一行中逆序输出3个字符，每个字符之间用空格分隔。在另一行中输出3个字符ASCII码值之和。</p>
<h3 id="输入样例-3"><a href="#输入样例-3" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>在这里给出一组输入。例如：</p>
<p>a b c<br>输出样例:<br>在这里给出相应的输出。例如：</p>
<p>c b a<br>294</p>
<pre class="line-numbers language-c" data-language="c"><code class="language-c"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;string.h></span></span>

<span class="token keyword">int</span> <span class="token function">get_ascii</span><span class="token punctuation">(</span><span class="token keyword">char</span> <span class="token operator">*</span>str<span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token keyword">int</span> num  <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">size_t</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token function">strlen</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        num <span class="token operator">+=</span>str<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token punctuation">&#125;</span>
    <span class="token keyword">return</span> num<span class="token punctuation">;</span>

<span class="token punctuation">&#125;</span>
<span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token keyword">char</span> str<span class="token punctuation">[</span><span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%s %s %s"</span><span class="token punctuation">,</span> str<span class="token punctuation">,</span>str<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">,</span>str<span class="token operator">+</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%c %c %c\n"</span><span class="token punctuation">,</span>str<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span>str<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">,</span>str<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> result <span class="token operator">=</span> <span class="token function">get_ascii</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%d"</span><span class="token punctuation">,</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-1-计算圆球体积"><a href="#7-1-计算圆球体积" class="headerlink" title="7-1 计算圆球体积"></a>7-1 计算圆球体积</h2><p>设圆球的半径为r，计算并输出圆球体积v。输出结果保留2位小数。提示：计算圆球的体积公式为：v=<br>3<br>4<br>​<br> πr<br>3<br>  (π=3.14)</p>
<h3 id="输入格式-4"><a href="#输入格式-4" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入第一行给出一个正整数半径r（0&lt; r ≤ 100）。</p>
<p>输出格式:<br>圆球的体积v保留两位小数。</p>
<h3 id="输入样例-4"><a href="#输入样例-4" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>5<br>输出样例:<br>v = 523.33</p>
<pre class="line-numbers language-c" data-language="c"><code class="language-c"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;math.h></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">PI</span> <span class="token expression"><span class="token number">3.14f</span></span></span>

<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token keyword">int</span>  r<span class="token punctuation">;</span>
    <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%d"</span><span class="token punctuation">,</span><span class="token operator">&amp;</span>r<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">float</span> v <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">4</span><span class="token operator">/</span><span class="token number">3.0f</span><span class="token punctuation">)</span> <span class="token operator">*</span> PI <span class="token operator">*</span> <span class="token function">powf</span><span class="token punctuation">(</span>r<span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"v = %.2f"</span><span class="token punctuation">,</span> v<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-1-大小写字符转换"><a href="#7-1-大小写字符转换" class="headerlink" title="7-1 大小写字符转换"></a>7-1 大小写字符转换</h2><p>分数 10<br>作者 齐心<br>单位 湖北汽车工业学院<br>输入一个字符，如果是大写字母，将它转换成小写字母并输出；如果是小写字母，将它转换成大写字母并输出；如果都不是，则输出：error</p>
<h3 id="输入样例-5"><a href="#输入样例-5" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>a<br>输出样例:<br>A</p>
<h3 id="输入样例-6"><a href="#输入样例-6" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>B<br>输出样例:<br>b</p>
<h3 id="输入样例-7"><a href="#输入样例-7" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>1</p>
<h3 id="输出样例-3"><a href="#输出样例-3" class="headerlink" title="输出样例:"></a>输出样例:</h3><p>error</p>
<pre class="line-numbers language-c" data-language="c"><code class="language-c"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>

<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token keyword">char</span> msg<span class="token punctuation">;</span>
    <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%c"</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>msg<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token string">'A'</span> <span class="token operator">&lt;=</span> msg <span class="token operator">&amp;&amp;</span> msg <span class="token operator">&lt;=</span> <span class="token string">'Z'</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        msg <span class="token operator">=</span> msg <span class="token operator">+</span> <span class="token number">32</span><span class="token punctuation">;</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%c"</span><span class="token punctuation">,</span> msg<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token string">'a'</span> <span class="token operator">&lt;=</span> msg <span class="token operator">&amp;&amp;</span> msg <span class="token operator">&lt;=</span> <span class="token string">'b'</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        msg <span class="token operator">=</span> msg <span class="token operator">-</span> <span class="token number">32</span><span class="token punctuation">;</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%c"</span><span class="token punctuation">,</span> msg<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
    <span class="token keyword">else</span>
    <span class="token punctuation">&#123;</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"error"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>

    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-4-计算工资"><a href="#7-4-计算工资" class="headerlink" title="7-4 计算工资"></a>7-4 计算工资</h2><p>分数 10<br>作者 沈睿<br>单位 浙江大学<br>某公司员工的工资计算方法如下：一周内工作时间不超过40小时，按正常工作时间计酬；超出40小时的工作时间部分，按正常工作时间报酬的1.5倍计酬。员工按进公司时间分为新职工和老职工，进公司不少于5年的员工为老职工，5年以下的为新职工。新职工的正常工资为30元/小时，老职工的正常工资为50元/小时。请按该计酬方式计算员工的工资。</p>
<p>输入格式：<br>输入在一行中给出2个正整数，分别为某员工入职年数和周工作时间，其间以空格分隔。</p>
<p>输出格式：<br>在一行输出该员工的周薪，精确到小数点后2位。</p>
<p>输入样例1：<br>5 40<br>输出样例1：<br>2000.00<br>输入样例2：<br>3 50<br>输出样例2：<br>1650.00</p>
<pre class="line-numbers language-c" data-language="c"><code class="language-c"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>
<span class="token keyword">int</span> <span class="token function">calculate</span><span class="token punctuation">(</span><span class="token keyword">int</span> year<span class="token punctuation">,</span> <span class="token keyword">int</span> weekHour<span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token keyword">int</span> price<span class="token punctuation">;</span>
    <span class="token keyword">float</span> salary<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>year <span class="token operator">>=</span> <span class="token number">5</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        price <span class="token operator">=</span> <span class="token number">50</span><span class="token punctuation">;</span>
        salary <span class="token operator">=</span> weekHour <span class="token operator">></span> <span class="token number">40</span> <span class="token operator">?</span> <span class="token punctuation">(</span>weekHour <span class="token operator">-</span> <span class="token number">40</span><span class="token punctuation">)</span> <span class="token operator">*</span> <span class="token number">1.5</span> <span class="token operator">*</span> price <span class="token operator">+</span> <span class="token number">2000</span> <span class="token operator">:</span> weekHour <span class="token operator">*</span> price<span class="token punctuation">;</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%.2f\n"</span><span class="token punctuation">,</span> salary<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
    <span class="token keyword">else</span>
    <span class="token punctuation">&#123;</span>
        price <span class="token operator">=</span> <span class="token number">30</span><span class="token punctuation">;</span>

        salary <span class="token operator">=</span> weekHour <span class="token operator">></span> <span class="token number">40</span> <span class="token operator">?</span> <span class="token punctuation">(</span>weekHour <span class="token operator">-</span> <span class="token number">40</span><span class="token punctuation">)</span> <span class="token operator">*</span> <span class="token number">1.5</span> <span class="token operator">*</span> price <span class="token operator">+</span> <span class="token number">1200</span> <span class="token operator">:</span> weekHour <span class="token operator">*</span> price<span class="token punctuation">;</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%.2f\n"</span><span class="token punctuation">,</span> salary<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>

    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>

<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token comment">// 入职年数</span>
    <span class="token keyword">int</span> year<span class="token punctuation">;</span>
    <span class="token comment">// 周工作时间</span>
    <span class="token keyword">int</span> weekHour<span class="token punctuation">;</span>
    <span class="token comment">// 工资</span>
    <span class="token keyword">float</span> salary<span class="token punctuation">;</span>
    <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%d %d"</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>year<span class="token punctuation">,</span> <span class="token operator">&amp;</span>weekHour<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">calculate</span><span class="token punctuation">(</span>year<span class="token punctuation">,</span> weekHour<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-3-计算符号函数的值"><a href="#7-3-计算符号函数的值" class="headerlink" title="7-3 计算符号函数的值"></a>7-3 计算符号函数的值</h2><p>分数 10<br>作者 C课程组<br>单位 浙江大学<br>对于任一整数n，符号函数sign(n)的定义如下：</p>
<p>请编写程序计算该函数对任一输入整数的值。</p>
<h3 id="输入格式-5"><a href="#输入格式-5" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入在一行中给出整数n。</p>
<p>输出格式:<br>在一行中按照格式“sign(n) = 函数值”输出该整数n对应的函数值。</p>
<p>输入样例1:<br>10<br>输出样例1:<br>sign(10) = 1<br>输入样例2:<br>0<br>输出样例2:<br>sign(0) = 0<br>输入样例3:<br>-98<br>输出样例3:<br>sign(-98) = -1</p>
<pre class="line-numbers language-c" data-language="c"><code class="language-c"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>

<span class="token keyword">int</span> <span class="token function">sign</span><span class="token punctuation">(</span><span class="token keyword">int</span> n<span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>n <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        <span class="token keyword">return</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>n <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
    <span class="token keyword">else</span>
    <span class="token punctuation">&#123;</span>
        <span class="token keyword">return</span> <span class="token number">1</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
<span class="token punctuation">&#125;</span>
<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token keyword">int</span> num<span class="token punctuation">;</span>
    <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%d"</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>num<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"sign(%d) = %d"</span><span class="token punctuation">,</span> num<span class="token punctuation">,</span> <span class="token function">sign</span><span class="token punctuation">(</span>num<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-1-统计学生成绩"><a href="#7-1-统计学生成绩" class="headerlink" title="7-1 统计学生成绩"></a>7-1 统计学生成绩</h2><p>分数 10<br>作者 陈建海<br>单位 浙江大学<br>本题要求编写程序读入N个学生的百分制成绩，统计五分制成绩的分布。百分制成绩到五分制成绩的转换规则：</p>
<p>大于等于90分为A；<br>小于90且大于等于80为B；<br>小于80且大于等于70为C；<br>小于70且大于等于60为D；<br>小于60为E。</p>
<h3 id="输入格式-6"><a href="#输入格式-6" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入在第一行中给出一个正整数N（≤1000），即学生人数；第二行中给出N个学生的百分制成绩，其间以空格分隔。</p>
<p>输出格式:<br>在一行中输出A、B、C、D、E对应的五分制成绩的人数分布，数字间以空格分隔，行末不得有多余空格。</p>
<h3 id="输入样例-8"><a href="#输入样例-8" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>7<br>77 54 92 73 60 65 69<br>输出样例:<br>1 0 2 3 1</p>
<pre class="line-numbers language-c" data-language="c"><code class="language-c"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>

<span class="token keyword">void</span> <span class="token function">judge</span><span class="token punctuation">(</span><span class="token keyword">int</span> score<span class="token punctuation">,</span> <span class="token keyword">int</span> <span class="token operator">*</span>grade<span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>score <span class="token operator">>=</span> <span class="token number">90</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        grade<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token operator">++</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>score <span class="token operator">&lt;</span> <span class="token number">90</span> <span class="token operator">&amp;&amp;</span> score <span class="token operator">>=</span> <span class="token number">80</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        grade<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token operator">++</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>score <span class="token operator">&lt;</span> <span class="token number">80</span> <span class="token operator">&amp;&amp;</span> score <span class="token operator">>=</span> <span class="token number">70</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        grade<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token operator">++</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>score <span class="token operator">&lt;</span> <span class="token number">70</span> <span class="token operator">&amp;&amp;</span> score <span class="token operator">>=</span> <span class="token number">60</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        grade<span class="token punctuation">[</span><span class="token number">3</span><span class="token punctuation">]</span><span class="token operator">++</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>score <span class="token operator">&lt;</span> <span class="token number">60</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        grade<span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">]</span><span class="token operator">++</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
<span class="token punctuation">&#125;</span>

<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token comment">// 分数</span>
    <span class="token keyword">int</span> score<span class="token punctuation">;</span>
    <span class="token comment">// 装成绩成绩人数分布，初始化</span>
    <span class="token keyword">int</span> grade<span class="token punctuation">[</span><span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">size_t</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">5</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        grade<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>

    <span class="token comment">// 读取人数</span>
    <span class="token keyword">int</span> times<span class="token punctuation">;</span>
    <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%d"</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>times<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 循环读取分数</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">size_t</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> times<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%d"</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>score<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">judge</span><span class="token punctuation">(</span>score<span class="token punctuation">,</span> grade<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>

    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">size_t</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">5</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>i <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span>
        <span class="token punctuation">&#123;</span>
            <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%d"</span><span class="token punctuation">,</span> grade<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">&#125;</span>
        <span class="token keyword">else</span>
        <span class="token punctuation">&#123;</span>
            <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">" %d"</span><span class="token punctuation">,</span> grade<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">&#125;</span>
    <span class="token punctuation">&#125;</span>

    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-3-统计素数并求和"><a href="#7-3-统计素数并求和" class="headerlink" title="7-3 统计素数并求和"></a>7-3 统计素数并求和</h2><p>分数 10<br>作者 张彤彧<br>单位 浙江大学<br>本题要求统计给定整数M和N区间内素数的个数并对它们求和。</p>
<h3 id="输入格式-7"><a href="#输入格式-7" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入在一行中给出两个正整数M和N（1≤M≤N≤500）。</p>
<h3 id="输出格式-3"><a href="#输出格式-3" class="headerlink" title="输出格式:"></a>输出格式:</h3><p>在一行中顺序输出M和N区间内素数的个数以及它们的和，数字间以空格分隔。</p>
<h3 id="输入样例-9"><a href="#输入样例-9" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>10 31<br>输出样例:<br>7 143</p>
<pre class="line-numbers language-c" data-language="c"><code class="language-c"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>

<span class="token keyword">int</span> <span class="token function">judge</span><span class="token punctuation">(</span><span class="token keyword">int</span> i<span class="token punctuation">,</span> <span class="token keyword">int</span> <span class="token operator">*</span>sum<span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token comment">// 判断i是否为素数</span>
    <span class="token keyword">int</span> o <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token punctuation">;</span> o <span class="token operator">&lt;</span> i<span class="token punctuation">;</span> o<span class="token operator">++</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        <span class="token comment">// 符合此条件则不为素数</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>i <span class="token operator">%</span> o <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span>
        <span class="token punctuation">&#123;</span>
            <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
        <span class="token punctuation">&#125;</span>
    <span class="token punctuation">&#125;</span>
    <span class="token comment">// 如果为素数，则返回1，并累计加和。</span>
    <span class="token operator">*</span>sum <span class="token operator">+=</span> i<span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>

<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token comment">// 本题要求统计给定整数M和N区间内素数的个数并对它们求和。</span>
    <span class="token comment">// 输入样例10 31 正整数M和N</span>

    <span class="token keyword">int</span> m<span class="token punctuation">,</span> n<span class="token punctuation">,</span> flag<span class="token punctuation">,</span> i<span class="token punctuation">,</span> total<span class="token punctuation">,</span> sum<span class="token punctuation">;</span>
    total <span class="token operator">=</span> flag <span class="token operator">=</span> sum <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%d %d"</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>m<span class="token punctuation">,</span> <span class="token operator">&amp;</span>n<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">// 外循环m到n个数字</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span>i <span class="token operator">=</span> m<span class="token punctuation">;</span> i <span class="token operator">&lt;=</span> n<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>i <span class="token operator">==</span> <span class="token number">1</span><span class="token punctuation">)</span>
        <span class="token punctuation">&#123;</span>
            <span class="token keyword">continue</span><span class="token punctuation">;</span>
        <span class="token punctuation">&#125;</span>
        <span class="token comment">// 如果判断为素数，那么素数总数加一</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token function">judge</span><span class="token punctuation">(</span>i<span class="token punctuation">,</span> <span class="token operator">&amp;</span>sum<span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">1</span><span class="token punctuation">)</span>
            total<span class="token operator">++</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%d %d\n"</span><span class="token punctuation">,</span> total<span class="token punctuation">,</span> sum<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-1-重要的话说三遍"><a href="#7-1-重要的话说三遍" class="headerlink" title="7-1 重要的话说三遍"></a>7-1 重要的话说三遍</h2><p>这道超级简单的题目没有任何输入。</p>
<p>你只需要把这句很重要的话 —— “I’m gonna WIN!”——连续输出三遍就可以了。</p>
<p>注意每遍占一行，除了每行的回车不能有任何多余字符。</p>
<pre class="line-numbers language-C" data-language="C"><code class="language-C">#include &lt;stdio.h&gt;

int main()
&#123;
    for (size_t i &#x3D; 0; i &lt; 3; i++)
    &#123;
        printf(&quot;I&#39;m gonna WIN!&quot;);
        if (i&lt;2)
        &#123;
            putchar(&#39;\n&#39;);
        &#125;

    &#125;

    return 0;
&#125;<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-2-输出倒三角图案"><a href="#7-2-输出倒三角图案" class="headerlink" title="7-2 输出倒三角图案"></a>7-2 输出倒三角图案</h2><p>本题要求编写程序，输出指定的由“*”组成的倒三角图案。</p>
<h4 id="输入格式-8"><a href="#输入格式-8" class="headerlink" title="输入格式:"></a>输入格式:</h4><p>本题目没有输入。</p>
<h4 id="输出格式-4"><a href="#输出格式-4" class="headerlink" title="输出格式:"></a>输出格式:</h4><p>按照下列格式输出由“*”组成的倒三角图案。</p>
<p><strong>简单实现</strong></p>
<pre class="line-numbers language-C" data-language="C"><code class="language-C">#include &lt;stdio.h&gt;

int main()
&#123;
    printf(&quot;* * * *\n&quot;);
    printf(&quot; * * *\n&quot;);
    printf(&quot;  * *\n&quot;);
    printf(&quot;   *&quot;);
    return 0;
&#125;<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<p>稍微复杂的代码</p>
<pre class="line-numbers language-C" data-language="C"><code class="language-C">#include &lt;stdio.h&gt;
int main()
&#123;

    int i, j;
    for (i &#x3D; 0; i &lt; 4; i++)
    &#123;
        for (j &#x3D; 0; j &lt; i; j++)
            putchar(&#39; &#39;); &#x2F;&#x2F; 前面的空格
        for (j &#x3D; 4 - j; j &gt; 0; j--)
        &#123;
            putchar(&#39;*&#39;);
            putchar(&#39; &#39;); &#x2F;&#x2F; 中间的空格
        &#125;
        if (i !&#x3D; 3)
        &#123;
            putchar(&#39;\n&#39;);
        &#125;
    &#125;
    return 0;
&#125;<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-3-打印菜单"><a href="#7-3-打印菜单" class="headerlink" title="7-3 打印菜单"></a>7-3 打印菜单</h2><p>本题要求编写程序，在屏幕上打印5行菜单。</p>
<h3 id="输入格式-9"><a href="#输入格式-9" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>本题目没有输入。</p>
<h3 id="输出格式-5"><a href="#输出格式-5" class="headerlink" title="输出格式:"></a>输出格式:</h3><p>按照下列格式打印菜单，每行显示一句。注意除了每行的换行不能有任何多余字符。</p>
<p>[1] Select crisps</p>
<p>[2] Select popcorn</p>
<p>[3] Select chocolate</p>
<p>[4] Select cola</p>
<p>[0] Exit</p>
<pre class="line-numbers language-C" data-language="C"><code class="language-C">#include &lt;stdio.h&gt;
int main()
&#123;
    char *message &#x3D; &quot;Select&quot;;
    printf(&quot;[1] %s crisps\n&quot;, message);
    printf(&quot;[2] %s popcorn\n&quot;, message);
    printf(&quot;[3] %s chocolate\n&quot;, message);
    printf(&quot;[4] %s cola\n&quot;, message);
    printf(&quot;[0] Exit\n&quot;);

    return 0;
&#125;<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-2-介绍一下你自己"><a href="#7-2-介绍一下你自己" class="headerlink" title="7-2 介绍一下你自己"></a>7-2 介绍一下你自己</h2><p>本题目要求输入你的姓名、年龄和籍贯，然后输出一个自我介绍的字符串。</p>
<h3 id="输入格式-10"><a href="#输入格式-10" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入你的姓名、年龄和籍贯。</p>
<h3 id="输出格式-6"><a href="#输出格式-6" class="headerlink" title="输出格式:"></a>输出格式:</h3><p>对每一组输入，在一行中输出一个自我介绍的字符串。</p>
<h3 id="输入样例-10"><a href="#输入样例-10" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>  小明</p>
<p>  20</p>
<p>  北京</p>
<h3 id="输出样例-4"><a href="#输出样例-4" class="headerlink" title="输出样例:"></a>输出样例:</h3><p>  大家好！我是小明，今年20岁，来自北京。</p>
<pre class="line-numbers language-Python" data-language="Python"><code class="language-Python">name &#x3D; input()
age &#x3D; input()
place &#x3D; input()
msg &#x3D; f&quot;大家好！我是&#123;name&#125;，今年&#123;age&#125;岁，来自&#123;place&#125;。&quot;
print(msg)<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-3-美化姓名"><a href="#7-3-美化姓名" class="headerlink" title="7-3 美化姓名"></a>7-3 美化姓名</h2><p>输入姓名，美化后输出。</p>
<h3 id="输入格式-11"><a href="#输入格式-11" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入一个姓名，如“<code>张无忌</code>”、“<code>哪吒</code>”、“<code>Fiona</code>”</p>
<h3 id="输出格式-7"><a href="#输出格式-7" class="headerlink" title="输出格式:"></a>输出格式:</h3><p>在姓名的左右各加上一个星号，如“<code>*张无忌*</code>”、“<code>*哪吒*</code>”、“<code>*Fiona*</code>”</p>
<h3 id="输入样例-11"><a href="#输入样例-11" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>在这里给出一组输入。例如：</p>
<p>  Tom</p>
<h3 id="输出样例-5"><a href="#输出样例-5" class="headerlink" title="输出样例:"></a>输出样例:</h3><p>在这里给出相应的输出。例如：</p>
<p>  <em>Tom</em></p>
<pre class="line-numbers language-Python" data-language="Python"><code class="language-Python">msg &#x3D; input()
print(f&quot;*&#123;msg&#125;*&quot;)<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre>

<h2 id="7-4-半圆弧的长度"><a href="#7-4-半圆弧的长度" class="headerlink" title="7-4 半圆弧的长度"></a>7-4 半圆弧的长度</h2><p>输入圆的半径，求半圆弧的长度（使用math库的pi常量）</p>
<h3 id="输入格式-12"><a href="#输入格式-12" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入圆的半径，可以是小数，也可以是整数。</p>
<h3 id="输出格式-8"><a href="#输出格式-8" class="headerlink" title="输出格式:"></a>输出格式:</h3><p>输出结果，要求结果保留2位小数。输出格式为：L=×××</p>
<h3 id="输入样例-12"><a href="#输入样例-12" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>在这里给出一组输入。例如：</p>
<p>  2</p>
<h3 id="输出样例-6"><a href="#输出样例-6" class="headerlink" title="输出样例:"></a>输出样例:</h3><p>在这里给出相应的输出。例如：</p>
<p>  L=6.28</p>
<pre class="line-numbers language-Python" data-language="Python"><code class="language-Python">from math import pi
receive &#x3D; float(input())*pi
print(&quot;L&#x3D;%.2f&quot;%receive,end&#x3D;&#39;&#39;)<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre>

<h2 id="7-5-输出工资表"><a href="#7-5-输出工资表" class="headerlink" title="7-5 输出工资表"></a>7-5 输出工资表</h2><p>现要求打印一份员工工资，输入员工的姓名、每小时收入、工作时长，税率和养老金比例，计算员工的净收入并输出相应的信息。<br>员工的工资 = 每小时收入 * 工作时长<br>税费 = 工资 * 税率<br>养老金 = 工资 * 养老金比例<br>净收入 = 工资 - 税费 - 养老金</p>
<h3 id="输入格式-13"><a href="#输入格式-13" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入共5行，每一行依次为员工的姓名、工作时长、每小时收入、税率和养老金比例</p>
<h3 id="输出格式-9"><a href="#输出格式-9" class="headerlink" title="输出格式:"></a>输出格式:</h3><p>依次在每一行输出：姓名、工作小时、每小时收入、工资、扣除金额、净收入</p>
<h3 id="输入样例-13"><a href="#输入样例-13" class="headerlink" title="输入样例:"></a>输入样例:</h3><p>在这里给出一组输入。例如：</p>
<p>  于敏</p>
<p>  8</p>
<p>  110</p>
<p>  0.1</p>
<p>  0.05</p>
<h3 id="输出样例-7"><a href="#输出样例-7" class="headerlink" title="输出样例:"></a>输出样例:</h3><p>在这里给出相应的输出。例如：</p>
<p>  Employee Name: 于敏</p>
<p>  Hours Worked:  8</p>
<p>  Pay Rate: $110</p>
<p>  Gross Pay: $880</p>
<p>  Deductions: 132.0</p>
<p>  Net Pay:748.0</p>
<pre class="line-numbers language-Python" data-language="Python"><code class="language-Python">def calculate():

    # 姓名
    name &#x3D; input()
    # 工作时长
    durable &#x3D; int(input())
    # 每小时收入
    hourly_revenue &#x3D; int(input())
    # 税率
    rate &#x3D; float(input())
    # 养老金比例
    pension_rate &#x3D; float(input())

    &quot;&quot;&quot;
    员工的工资 &#x3D; 每小时收入 * 工作时长
    税费 &#x3D; 工资 * 税率
    养老金 &#x3D; 工资 * 养老金比例
    净收入 &#x3D; 工资 - 税费 - 养老金
    &quot;&quot;&quot;
    salary &#x3D; hourly_revenue*durable
    rate_free &#x3D; salary*rate
    pension &#x3D; salary*pension_rate
    net_income &#x3D; salary-rate_free-pension
    out &#x3D; &#39;&#39;&#39;Employee Name: &#123;0&#125;

Hours Worked:  &#123;1&#125;
Pay Rate: $&#123;2&#125;
Gross Pay: $&#123;3&#125;
Deductions: &#123;4&#125;
Net Pay:&#123;5&#125;&#39;&#39;&#39;.format(name,durable,hourly_revenue,salary,rate_free+pension,net_income)
    print(out)

if __name__&#x3D;&#x3D;&quot;__main__&quot;:
    calculate()<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-2-逆序的三位数"><a href="#7-2-逆序的三位数" class="headerlink" title="7-2 逆序的三位数"></a>7-2 逆序的三位数</h2><p>分数 5<br>作者 翁恺<br>单位 浙江大学<br>程序每次读入一个正3位数，然后输出按位逆序的数字。注意：当输入的数字含有结尾的0时，输出不应带有前导的0。比如输入700，输出应该是7。</p>
<h3 id="输入格式："><a href="#输入格式：" class="headerlink" title="输入格式："></a>输入格式：</h3><p>每个测试是一个3位的正整数。</p>
<h3 id="输出格式："><a href="#输出格式：" class="headerlink" title="输出格式："></a>输出格式：</h3><p>输出按位逆序的数。</p>
<h3 id="输入样例："><a href="#输入样例：" class="headerlink" title="输入样例："></a>输入样例：</h3><p><code>123</code></p>
<h3 id="输出样例："><a href="#输出样例：" class="headerlink" title="输出样例："></a>输出样例：</h3><p><code>321</code></p>
<pre class="line-numbers language-c" data-language="c"><code class="language-c"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>

<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token keyword">int</span> num<span class="token punctuation">,</span> ge<span class="token punctuation">,</span> shi<span class="token punctuation">,</span> bai<span class="token punctuation">;</span>
    <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%d"</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>num<span class="token punctuation">)</span><span class="token punctuation">;</span>
    bai <span class="token operator">=</span> <span class="token punctuation">(</span>num <span class="token operator">-</span> num <span class="token operator">%</span> <span class="token number">100</span><span class="token punctuation">)</span> <span class="token operator">/</span> <span class="token number">100</span><span class="token punctuation">;</span>
    ge <span class="token operator">=</span> <span class="token punctuation">(</span>num <span class="token operator">-</span> bai <span class="token operator">*</span> <span class="token number">100</span><span class="token punctuation">)</span> <span class="token operator">%</span> <span class="token number">10</span><span class="token punctuation">;</span>
    shi <span class="token operator">=</span> <span class="token punctuation">(</span>num <span class="token operator">-</span> bai <span class="token operator">*</span> <span class="token number">100</span> <span class="token operator">-</span> ge<span class="token punctuation">)</span> <span class="token operator">/</span> <span class="token number">10</span><span class="token punctuation">;</span>
    num <span class="token operator">=</span> bai <span class="token operator">+</span> shi <span class="token operator">*</span> <span class="token number">10</span> <span class="token operator">+</span> ge <span class="token operator">*</span> <span class="token number">100</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%d\n"</span><span class="token punctuation">,</span> num<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-3-厘米换算英尺英寸"><a href="#7-3-厘米换算英尺英寸" class="headerlink" title="7-3 厘米换算英尺英寸"></a>7-3 厘米换算英尺英寸</h2><p>分数 5<br>作者 翁恺<br>单位 浙江大学<br>如果已知英制长度的英尺foot和英寸inch的值，那么对应的米是(foot+inch/12)×0.3048。现在，如果用户输入的是厘米数，那么对应英制长度的英尺和英寸是多少呢？别忘了1英尺等于12英寸。</p>
<h3 id="输入格式：-1"><a href="#输入格式：-1" class="headerlink" title="输入格式："></a>输入格式：</h3><p>输入在一行中给出1个正整数，单位是厘米。</p>
<h3 id="输出格式：-1"><a href="#输出格式：-1" class="headerlink" title="输出格式："></a>输出格式：</h3><p>在一行中输出这个厘米数对应英制长度的英尺和英寸的整数值，中间用空格分开。</p>
<h3 id="输入样例：-1"><a href="#输入样例：-1" class="headerlink" title="输入样例："></a>输入样例：</h3><p>170</p>
<h3 id="输出样例：-1"><a href="#输出样例：-1" class="headerlink" title="输出样例："></a>输出样例：</h3><p>5 6</p>
<pre class="line-numbers language-c" data-language="c"><code class="language-c"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;math.h></span></span>
<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token keyword">int</span> inch<span class="token punctuation">,</span> cm<span class="token punctuation">,</span> left<span class="token punctuation">,</span> right<span class="token punctuation">;</span>
    <span class="token keyword">float</span> foot<span class="token punctuation">;</span>
    <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%d"</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>cm<span class="token punctuation">)</span><span class="token punctuation">;</span>
    foot <span class="token operator">=</span> cm <span class="token operator">/</span> <span class="token number">30.48</span><span class="token punctuation">;</span>
    left <span class="token operator">=</span> <span class="token function">floor</span><span class="token punctuation">(</span>foot<span class="token punctuation">)</span><span class="token punctuation">;</span>
    right <span class="token operator">=</span> <span class="token function">floor</span><span class="token punctuation">(</span><span class="token punctuation">(</span>foot <span class="token operator">-</span> left<span class="token punctuation">)</span> <span class="token operator">*</span> <span class="token number">12</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%d %d"</span><span class="token punctuation">,</span> left<span class="token punctuation">,</span> right<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>



<h2 id="7-1-出租车计价"><a href="#7-1-出租车计价" class="headerlink" title="7-1 出租车计价"></a>7-1 出租车计价</h2><p>分数 10<br>作者 沈睿<br>单位 浙江大学<br>本题要求根据某城市普通出租车收费标准编写程序进行车费计算。具体标准如下：</p>
<p>起步里程为3公里，起步费10元；<br>超起步里程后10公里内，每公里2元；<br>超过10公里以上的部分加收50%的回空补贴费，即每公里3元；<br>营运过程中，因路阻及乘客要求临时停车的，按每5分钟2元计收（不足5分钟则不收费）。<br>输入格式:<br>输入在一行中给出输入行驶里程（单位为公里，精确到小数点后1位）与等待时间（整数，单位为分钟），其间以空格分隔。</p>
<h3 id="输出格式-10"><a href="#输出格式-10" class="headerlink" title="输出格式:"></a>输出格式:</h3><p>在一行中输出乘客应支付的车费（单位为元），结果四舍五入，保留到元。</p>
<h3 id="输入样例1"><a href="#输入样例1" class="headerlink" title="输入样例1:"></a>输入样例1:</h3><p>2.6 2</p>
<h3 id="输出样例1"><a href="#输出样例1" class="headerlink" title="输出样例1:"></a>输出样例1:</h3><p>10</p>
<h3 id="输入样例2"><a href="#输入样例2" class="headerlink" title="输入样例2:"></a>输入样例2:</h3><p>5.1 4</p>
<h3 id="输出样例2"><a href="#输出样例2" class="headerlink" title="输出样例2:"></a>输出样例2:</h3><p>14</p>
<h3 id="输入样例3"><a href="#输入样例3" class="headerlink" title="输入样例3:"></a>输入样例3:</h3><p>12.5 9</p>
<h3 id="输出样例3"><a href="#输出样例3" class="headerlink" title="输出样例3:"></a>输出样例3:</h3><p>34</p>
<pre class="line-numbers language-c" data-language="c"><code class="language-c"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;math.h></span></span>

<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token keyword">float</span> price<span class="token punctuation">,</span> distance<span class="token punctuation">;</span>
    <span class="token keyword">int</span> result<span class="token punctuation">,</span> wait_time<span class="token punctuation">,</span> wait_price<span class="token punctuation">;</span>
    <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%f %d"</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>distance<span class="token punctuation">,</span> <span class="token operator">&amp;</span>wait_time<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>distance <span class="token operator">&lt;=</span> <span class="token number">3</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        price <span class="token operator">+=</span> <span class="token number">10</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token number">3</span> <span class="token operator">&lt;</span> distance <span class="token operator">&amp;&amp;</span> distance <span class="token operator">&lt;=</span> <span class="token number">10</span><span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
        price <span class="token operator">=</span> <span class="token punctuation">(</span>distance <span class="token operator">-</span> <span class="token number">3</span><span class="token punctuation">)</span> <span class="token operator">*</span> <span class="token number">2</span> <span class="token operator">+</span> <span class="token number">10</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
    <span class="token keyword">else</span>
    <span class="token punctuation">&#123;</span>
        price <span class="token operator">=</span> <span class="token number">24</span> <span class="token operator">+</span> <span class="token punctuation">(</span>distance <span class="token operator">-</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token operator">*</span> <span class="token number">3</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>

    wait_price <span class="token operator">=</span> wait_time <span class="token operator">>=</span> <span class="token number">5</span> <span class="token operator">?</span> wait_time <span class="token operator">/</span> <span class="token number">5</span> <span class="token operator">*</span> <span class="token number">2</span> <span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">;</span>
    price <span class="token operator">+=</span> wait_price<span class="token punctuation">;</span>

    result <span class="token operator">=</span> <span class="token function">round</span><span class="token punctuation">(</span>price<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%d\n"</span><span class="token punctuation">,</span> result<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h2 id="7-2-计算油费"><a href="#7-2-计算油费" class="headerlink" title="7-2 计算油费"></a>7-2 计算油费</h2><p>分数 10<br>作者 颜晖<br>单位 浙大城市学院<br>现在90号汽油6.95元/升、93号汽油7.44元/升、97号汽油7.93元/升。为吸引顾客，某自动加油站推出了“自助服务”和“协助服务”两个服务等级，分别可得到5%和3%的折扣。</p>
<p>本题要求编写程序，根据输入顾客的加油量a，汽油品种b（90、93或97）和服务类型c（m - 自助，e - 协助），计算并输出应付款。</p>
<h3 id="输入格式：-2"><a href="#输入格式：-2" class="headerlink" title="输入格式："></a>输入格式：</h3><p>输入在一行中给出两个整数和一个字符，分别表示顾客的加油量a，汽油品种b（90、93或97）和服务类型c（m - 自助，e - 协助）。</p>
<h3 id="输出格式：-2"><a href="#输出格式：-2" class="headerlink" title="输出格式："></a>输出格式：</h3><p>在一行中输出应付款额，保留小数点后2位。</p>
<h3 id="输入样例：-2"><a href="#输入样例：-2" class="headerlink" title="输入样例："></a>输入样例：</h3><p>40 97 m</p>
<h3 id="输出样例：-2"><a href="#输出样例：-2" class="headerlink" title="输出样例："></a>输出样例：</h3><p>301.34</p>
<pre class="line-numbers language-c" data-language="c"><code class="language-c"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>
<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">&#123;</span>
    <span class="token keyword">int</span> oil<span class="token punctuation">,</span> oil_variety<span class="token punctuation">;</span>
    <span class="token keyword">char</span> server_type<span class="token punctuation">;</span>
    <span class="token keyword">float</span> total<span class="token punctuation">,</span> count<span class="token punctuation">,</span> price<span class="token punctuation">;</span>

    <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%d %d %c"</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>oil<span class="token punctuation">,</span> <span class="token operator">&amp;</span>oil_variety<span class="token punctuation">,</span> <span class="token operator">&amp;</span>server_type<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">switch</span> <span class="token punctuation">(</span>oil_variety<span class="token punctuation">)</span>
    <span class="token punctuation">&#123;</span>
    <span class="token keyword">case</span> <span class="token number">97</span><span class="token operator">:</span>
        price <span class="token operator">=</span> <span class="token number">7.93</span><span class="token punctuation">;</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>
    <span class="token keyword">case</span> <span class="token number">93</span><span class="token operator">:</span>
        price <span class="token operator">=</span> <span class="token number">7.44</span><span class="token punctuation">;</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>
    <span class="token keyword">default</span><span class="token operator">:</span>
        price <span class="token operator">=</span> <span class="token number">6.95</span><span class="token punctuation">;</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span>server_type <span class="token operator">==</span> <span class="token string">'m'</span><span class="token punctuation">)</span>
        count <span class="token operator">=</span> <span class="token number">0.95</span><span class="token punctuation">;</span>
    <span class="token keyword">else</span>
        count <span class="token operator">=</span> <span class="token number">0.97</span><span class="token punctuation">;</span>

    total <span class="token operator">=</span> price <span class="token operator">*</span> oil <span class="token operator">*</span> count<span class="token punctuation">;</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%.2f\n"</span><span class="token punctuation">,</span> total<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>


<h2 id="7-1-找出三位水仙花数"><a href="#7-1-找出三位水仙花数" class="headerlink" title="7-1 找出三位水仙花数"></a>7-1 找出三位水仙花数</h2><p>分数 10<br>作者 颜晖<br>单位 浙大城市学院<br>本题要求编写程序，输出给定正整数M和N区间内的所有三位水仙花数。三位水仙花数，即其个位、十位、百位数字的立方和等于该数本身。</p>
<h3 id="输入格式-14"><a href="#输入格式-14" class="headerlink" title="输入格式:"></a>输入格式:</h3><p>输入在一行中给出两个正整数M和N（100≤M≤N≤999）。</p>
<h3 id="输出格式-11"><a href="#输出格式-11" class="headerlink" title="输出格式:"></a>输出格式:</h3><p>顺序输出M和N区间内所有三位水仙花数，每一行输出一个数。若该区间内没有三位水仙花数，则无输出。</p>
<p>如果M或者N不符合题目的要求，则输出Invalid Value.。</p>
<h3 id="输入样例1-1"><a href="#输入样例1-1" class="headerlink" title="输入样例1:"></a>输入样例1:</h3><p>100 400</p>
<h3 id="输出样例1-1"><a href="#输出样例1-1" class="headerlink" title="输出样例1:"></a>输出样例1:</h3><p>153<br>370<br>371</p>
<h3 id="输入样例2-1"><a href="#输入样例2-1" class="headerlink" title="输入样例2:"></a>输入样例2:</h3><p>500 600</p>
<h3 id="输出样例2-1"><a href="#输出样例2-1" class="headerlink" title="输出样例2:"></a>输出样例2:</h3><h3 id="输入样例3："><a href="#输入样例3：" class="headerlink" title="输入样例3："></a>输入样例3：</h3><p>990 101</p>
<h3 id="输出样例3："><a href="#输出样例3：" class="headerlink" title="输出样例3："></a>输出样例3：</h3><p>Invalid Value.</p>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">hongzhe</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="http://huang-hongzhe.gitee.io/2022/10/06/PAT%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1%E4%B9%A0%E9%A2%98/">http://huang-hongzhe.gitee.io/2022/10/06/PAT%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1%E4%B9%A0%E9%A2%98/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/about" target="_blank">hongzhe</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84-%E7%AE%97%E6%B3%95/">
                                    <span class="chip bg-color">数据结构,算法</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    

    

</div>

                </div>
            </div>
            
        </div>
    </div>

    

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="far fa-dot-circle"></i>&nbsp;本篇
            </div>
            <div class="card">
                <a href="/2022/10/06/PAT%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1%E4%B9%A0%E9%A2%98/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/12.jpg" class="responsive-img" alt="PTA程序设计习题">
                        
                        <span class="card-title">PTA程序设计习题</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2022-10-06
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E7%BC%96%E7%A8%8B/" class="post-category">
                                    编程
                                </a>
                            
                            
                        </span>
                    </div>
                </div>

                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84-%E7%AE%97%E6%B3%95/">
                        <span class="chip bg-color">数据结构,算法</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2022/09/18/Vscode%E9%85%8D%E7%BD%AEC_C++%E7%8E%AF%E5%A2%83%E3%80%90%E9%80%82%E5%90%88%E5%B0%8F%E7%99%BD_%E5%85%8D%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E9%85%8D%E7%BD%AE%E3%80%91/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/8.jpg" class="responsive-img" alt="vsocde配置c/c++环境">
                        
                        <span class="card-title">vsocde配置c/c++环境</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2022-09-18
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E7%BC%96%E7%A8%8B/" class="post-category">
                                    编程
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/IDE/">
                        <span class="chip bg-color">IDE</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFunction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        font-size: 15px;
        color: blue;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="6717903070"
                   fixed='true'
                   autoplay='true'
                   theme='blue'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 15px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2021-2022</span>
            
            <span id="year">2021</span>
            <a href="/about" target="_blank">hongzhe</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <span id="sitetime">载入运行时间...</span>
            <script>
                function siteTime() {
                    var seconds = 1000;
                    var minutes = seconds * 60;
                    var hours = minutes * 60;
                    var days = hours * 24;
                    var years = days * 365;
                    var today = new Date();
                    var startYear = "2021";
                    var startMonth = "4";
                    var startDate = "11";
                    var startHour = "0";
                    var startMinute = "0";
                    var startSecond = "0";
                    var todayYear = today.getFullYear();
                    var todayMonth = today.getMonth() + 1;
                    var todayDate = today.getDate();
                    var todayHour = today.getHours();
                    var todayMinute = today.getMinutes();
                    var todaySecond = today.getSeconds();
                    var t1 = Date.UTC(startYear, startMonth, startDate, startHour, startMinute, startSecond);
                    var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond);
                    var diff = t2 - t1;
                    var diffYears = Math.floor(diff / years);
                    var diffDays = Math.floor((diff / days) - diffYears * 365);
                    var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours);
                    var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) /
                        minutes);
                    var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours -
                        diffMinutes * minutes) / seconds);
                    if (startYear == todayYear) {
                        document.getElementById("year").innerHTML = todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffDays + " 天 " + diffHours +
                            " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    } else {
                        document.getElementById("year").innerHTML = startYear + " - " + todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffYears + " 年 " + diffDays +
                            " 天 " + diffHours + " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    }
                }
                setInterval(siteTime, 1000);
            </script>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/2528104776" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:2528104776@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=2528104776" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 2528104776" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    <!--腾讯兔小巢-->
    
    

    

    

    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
